/*
 * Copyright (C) 2007,2008  Jonathan Hendler
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 * 
 * The authors can be contacted at: 
 * @author Jonathan Hendler [jonathan DOT hendler AT google DOT com]
 * 
 * @license GPLv2
 */

#ifndef NYMRL_HELPER_H_
#define NYMRL_HELPER_H_

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "lib/pstdint.h" /* Replace with <stdint.h> if appropriate */
#include <ctype.h>
#include <sys/types.h>


//#ifdef _OSD_POSIX
//#ifndef APACHE
//#error On this EBCDIC platform, PHP is only supported as an Apache module.
//#else /*APACHE*/
//#ifndef CHARSET_EBCDIC
//#define CHARSET_EBCDIC /* this machine uses EBCDIC, not ASCII! */
//#endif
//#include "ebcdic.h"
//#endif /*APACHE*/
//#endif /*_OSD_POSIX*/


#include "nymrl_message.h"

//http://www.adp-gmbh.ch/cpp/common/base64.html
//http://gd.tuwien.ac.at/infosys/mail/vm/base64-decode.c
//http://base64.sourceforge.net/b64.c

char * nymrl_base64_encode(char * str);
char * nymrl_base64_decode(char * str);
inline int nymrl_get_time();

/**
 * not actually using GUID.. just a random string generator
 * */
inline char *  nymrl_get_guid();

/**
 * CODE from : http://www.azillionmonkeys.com/qed/hash.html
 * other documentation
 */
uint32_t SuperFastHash (const char * data, int len);
unsigned long  nymrl_message_hash(char * data);

//php
inline char * nymrl_raw_url_encode(char const *s, int len, int * new_length);
//static int nymrl_htoi(char *s);
inline char * nymrl_raw_url_decode(char *str, int len);
//inline char * _nymrl_raw_url_decode( char * str, int len);


 //get first digit, second digit, third digt
 inline int nymrl_first(int digit);
 inline int nymrl_second(int digit);
 inline int nymrl_third(int digit);


#endif /*NYMRL_HELPER_H_*/
